﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using AutoMapper;

namespace ERPStore.NewsLetters.Mapping
{
	public class NewsLetterTitleResolver : ValueResolver<Models.NewsLetter, string>
	{
		protected override string ResolveCore(Models.NewsLetter source)
		{
			var match = System.Text.RegularExpressions.Regex.Match(source.Content, @"<title>(?<t>[^<]*)</title>");
			if (match.Success)
			{
				return match.Groups["t"].Value;
			}
			return "sans titre";
		}
	}
}
